package com.华为OD;

import java.util.Scanner;

public class t5数据分类 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int c = in.nextInt(),b = in.nextInt();
        int[] ncls = new int[c];
        for (int i = 0; i < 10; i++) {
            int a = in.nextInt();
            int sum = 0;
            while (a!=0){
                sum += a%256;
                a=a/256;
            }
            int cls = sum%b;
            if(cls<c)
                ncls[cls]++;
        }
        int ans = 0;
        for (int i = 0; i < c; i++) {
            if(ncls[i]>ans)
                ans = ncls[i];
        }
        System.out.println(ans);
    }
}
